package org.wsjy.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.wsjy.exception.NullException;
import org.wsjy.model.TDevice;
import org.wsjy.model.THomeShow;
import org.wsjy.model.TService;
import org.wsjy.service.DeviceService;
import org.wsjy.service.HomeShowService;
import org.wsjy.service.ServiceService;

/**
 * 首页管理
 * 
 * @Title:
 * @Company:万世极缘工作室
 * @Description:
 * @Author:万世极缘
 * @Since:2016年1月15日
 * @Copyright:Copyright (c) 2014
 * @ModifyDate:
 * @Version:1.1.0
 */
@Controller
public class IndexController {
    @Autowired
    private HomeShowService homeShowService;
    @Autowired
    private ServiceService serviceService;
    @Autowired
    private DeviceService DeviceService;
    /**
     * 
     * @return
     */
    @RequestMapping(value = {"/index.*", "/index"})
    public String index(ModelMap model, HttpServletRequest request) {
        // home_index初始化
        try {
            // 首页流动展示
            Map<String, List<THomeShow>> homeShowListMap = homeShowService.findList();
            // 服务内容展示
            List<TService> serviceList = serviceService.findAll();
            // 设备展示
            List<TDevice> deviceList = DeviceService.findAll();
            
            model.addAttribute("homeShowMap", homeShowListMap);
            model.addAttribute("serviceList", serviceList);
            model.addAttribute("deviceList", deviceList);
        } catch (NullException e) {
            model.addAttribute("errorMsg", e.getErrorMsg());
            e.printStackTrace();
        }
        return "index";
    }
}
